package com.fancymusic.controller;

import com.fancymusic.entity.BaseResult;
import com.fancymusic.entity.Manager;
import com.fancymusic.service.IManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("face")
//@CrossOrigin
public class ManagerControllerFace {

    @Autowired
    IManagerService iManagerService;

    @RequestMapping("login")
    public BaseResult<Manager> login(@RequestParam("name") String name){
        BaseResult<Manager> baseResult = new BaseResult<>();

        System.out.println("face---------login-------");
        System.out.println("face---------login-------");
        System.out.println("face---------login-------");
        System.out.println("face---------login-------");

        Manager m = new Manager();
        m.setUsername(name);
        Manager managerByName = iManagerService.getManagerByName(m);

        if (managerByName==null){
            baseResult.setMessage("用户不存在");
            baseResult.setState(false);
            return baseResult;
        }

        baseResult.setMessage("登录成功，点击登录");
        baseResult.setState(true);
        System.out.println("ManagerControllerFace===登录成功，点击登录===");
        return baseResult;
    }
}
